//王者地带
//2019-01-06

(function(window,document)
{
var App=
{
  openApp:function(type,data,fu)
  {
	  var type=type.toLowerCase();
	  var type_array={"taobao":"taobao://","jd":"openApp.jdMobile://","pinduoduo":"pinduoduo://"}; 
	  var pname={"taobao":"com.taobao.taobao","jd":"com.jingdong.app.mall","pinduoduo":"com.xunmeng.pinduoduo"};
	  var error={}; 
	   if(typeof type_array[type]=="undefined")
	   {
		error={"code":"1","message":type+":名称错误或不存在!"};
		fu(error);
		return;
	   }
		if(typeof data.goosid=="undefined")
		{
		error={"code":"2","message":"goosid:参数必须填写!"};
		fu(error);
		return;
		}	  
		if(data.goosid=="")
		{
		error={"code":"3","message":"goosid:必须填写商品的ID!"};
		fu(error);
		return;
		}	  
	   if(!plus.runtime.isApplicationExist({pname:pname[type],action:type_array[type]}))
		{		
		error={"code":"4","message":type+":应用未安装"};
		fu(error);
		return;			
		}   
		var iosjd="openApp.jdMobile://virtual?params=%7B%22sourceValue%22:%220_productDetail_97%22,%22des%22:%22productDetail%22,%22skuId%22:%22"+data.goosid+"%22,%22category%22:%22jump%22,%22sourceType%22:%22PCUBE_CHANNEL%22%7D";	
		var openURL={"taobao":"taobao://item.taobao.com/item.htm?id="+data.goosid+"",
		"jd":(mui.os.ios?iosjd:"openApp.jdMobile://virtual?params={\"category\":\"jump\",\"des\":\"productDetail\",\"skuId\":\""+data.goosid+"\",\"sourceType\":\"JSHOP_SOURCE_TYPE\",\"sourceValue\":\"JSHOP_SOURCE_VALUE\"}"),
		"pinduoduo":"pinduoduo://com.xunmeng.pinduoduo/duo_coupon_landing.html?goods_id="+data.goosid+"",
		};
		plus.runtime.openURL(openURL[type], function(e) 
			{
			error={"code":"5","message":e};
			fu(error);	
			},pname[type]);	
  }
};		
window.App=App; 
}(window,document));	